<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="redis" uri="http://www.shopjsp.com/redisTag/functions" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="basePath" value="${redis:getSysConfig('base_path_back')}"/>
<c:set var="uploadPath" value="${redis:getSysConfig('uploadFileVisitRoot')}"/>
<script type="text/javascript">
    /**
     * 自定义验证规则
     */
    function validateForm(){
        form.bootstrapValidator({
            message: "无效的值",
            feedbackIcons: {
                valid: "glyphicon glyphicon-ok",
                invalid: "glyphicon glyphicon-remove",
                validating: "glyphicon glyphicon-refresh"
            },
            fields: {
                econtent: {
                    validators: {
                        stringLength: {max: 150, message: "评价内容最大长度为100"}
                    }
                }
            }
        });
    }

    /**
     * 编辑评价信息
     */
	<shiro:hasPermission name="back_gotoEvaluateGoods_update">
    function editInfo(){
        $("#myModalLabel").empty().text("修改评价信息");
        /**获取选中行的id**/
        var selectedRow= $("#tt").bootstrapTable('getSelections');
        if(selectedRow.length==1){
            var id=selectedRow[0].evaluateId;
            $("#btn_edit").attr("data-target","#addOrEditModal");/**选中了记录后才可打开对应的模态框**/
            $.ajax({
                type: "POST",
                dataType: "JSON",
                url: "${basePath}/back/evalGoods/getEvaluateGoods.sjson",
                data: {evaluateId:id},
                success: function(result){
                    var data = JSON.parse(result.data);
                    /**隐藏域**/
                    $("#evaluateId").val(data.evaluateId);
                    /**可见表单控件**/
                    $("#ordersNo").html(data.ordersNo);
                    $("#shopName").html(data.shopName);
                    $("#productFullName").html(data.productFullName);
                    $("#salesPrice").html(data.salesPrice.toFixed(2));
                    $("#appraiserName").html(data.appraiserName);
                    if(data.level==1){
                        $("#level").html("<span class='color_001'>好评</span>");
                    }else if(data.level==0){
                        $("#level").html("<span class='color_003'>中评</span>");
                    }else if(data.level==-1){
                        $("#level").html("<span class='color_002'>差评</span>");
                    }
                    $("#createTime").html(new Date(data.createTime).Format("yyyy-MM-dd hh:mm:ss"));
                    $("#evaluateState_"+data.evaluateState).attr("checked",true);
                    $("#content").val(data.content);
                }
            });
        }else{
            $("#btn_edit").attr("data-target","");/**没有选中记录不可打开模态框**/
            showMsg("请选择一行记录！");
        }
    }
	</shiro:hasPermission>
</script>

<!--添加编辑模态框（Modal） -->
<div class="modal fade" id="addOrEditModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
	<div class="modal-dialog" style="width:70%">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h5 class="modal-title" id="myModalLabel"></h5>
			</div>
			<div class="modal-body">
				<form id="form1"  method="post" action="${basePath}/back/evalGoods/updateContentAndEvaluateState.sjson">
					<input id="evaluateId" type="hidden" name="evaluateId" noclear="true"/>
					<table align="center" class="addOrEditTable table-bordered table" style="width:100%;">
						<tr>
							<td class="toright_td" width="150px">订单号:</td>
							<td class="toleft_td">&nbsp;&nbsp;<span id="ordersNo"></span></td>
							<td class="toright_td" width="150px">店铺名称:</td>
							<td class="toleft_td">&nbsp;&nbsp;<span id="shopName"></span></td>
						</tr>
						<tr>
							<td class="toright_td" width="150px">商品名称:</td>
							<td class="toleft_td">&nbsp;&nbsp;<span id="productFullName"></span></td>
							<td class="toright_td" width="150px">商品价格:</td>
							<td class="toleft_td">&nbsp;&nbsp;￥<span id="salesPrice"></span></td>
						</tr>
						<tr>
							<td class="toright_td" width="150px">评价人:</td>
							<td class="toleft_td" >&nbsp;&nbsp;<span id="appraiserName"></span></td>
							<td class="toright_td" width="150px">评价等级:</td>
							<td class="toleft_td">&nbsp;&nbsp;<span id="level"></span></td>
						</tr>
						<tr>
							<td class="toright_td" width="150px">评价时间:</td>
							<td class="toleft_td">&nbsp;&nbsp;<span id="createTime"></span></td>
							<td class="toright_td" width="150px">评价状态:</td>
							<td class="toleft_td">&nbsp;&nbsp;
								<input  type="radio" name="evaluateState" class="radioInput" value="0" checked="checked"/>正常显示&nbsp;&nbsp;
								<input  type="radio" name="evaluateState" class="radioInput" value="1"/>禁止显示
							</td>
						</tr>
						<tr>
							<td class="toright_td" width="150px"><span style="color:red">* </span>评价内容:&nbsp;&nbsp;</td>
							<td  class="toleft_td" colspan="3">
								<div class="form-group">
									<textarea class="form-control input-sm" type="text" id="content" name="content" placeholder="请输入评价内容"></textarea>
								</div>
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" id="validateBtn" class="btn btn-primary"  onclick="submitForm()">保存</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
